<!DOCTYPE html>
<!-- 网页使用的语言 -->
<html lang="en">
<head>
  <!-- 指定字符集 -->
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>原材料管理</title>

  <link href="css/bootstrap.min.css" rel="stylesheet">
  <script src="js/bootstrap.min.js"></script>
  <script type="text/javascript" src="js/jquery-3.4.1.js"></script>
  <script type="text/javascript" src="js/jquery.cookie.js"></script>


  <script type="text/javascript">
    $(function (){
      var id = $.cookie('the_cookie');
     $.ajax({
       type:"get",
       url:"manage/findmaterialById.do",
       data:{
         "id":id
       },
       dataType:"json",
       success:function (data){
         $("#id").val(data.id);
         $("#name").val(data.name);
         $("#num").val(data.num);
         $("#price").val(data.price);
       }
     })


      $("#tijiao").click(function (){
       var id=$("#id").val()
        var name = $("#name").val();
        var num = $("#num").val();
        var price = $("#price").val();
        $.ajax({
         type: "post",
         url: "manage/modifymaterial.do",
         data:{
           "id":id,
           "name":name,
           "num":num,
           "price":price
         },
         dataType: "json",
         success:function (data){
          if(data.result==1){
            alert("修改成功")
            location.href="shoop.html";
          }
         }
       })
      })
    })
  </script>

</head>
<body>
<div class="container" style="width: 400px;">
  <h3 style="text-align: center;">修改原材料信息</h3>
  <form id="modifydemo" action="manage/modifymaterial.do" method="post">
    <div class="form-group">
      <label for="id">编号：</label>
      <input type="text" class="form-control" id="id"  placeholder="请输入编号"/>
    </div>
    <div class="form-group">
      <label for="name">原材料：</label>
      <input type="text" class="form-control" id="name" readonly="readonly" placeholder="" />
    </div>

    <div class="form-group">
      <label for="num">数量：</label>
      <input type="text" class="form-control" id="num"  placeholder="请输入更改的数量" />
    </div>

    <div class="form-group">
      <label for="price">价格：</label>
      <input type="text" class="form-control" id="price" placeholder="请更改的价格" />
    </div>

    <div class="form-group" style="text-align: center">
      <input class="btn btn-primary" id="tijiao" type="submit" value="提交" />
      <input class="btn btn-default" type="reset" value="重置" />
      <input class="btn btn-default" type="button" value="返回"/>
    </div>
  </form>
</div>
</body>
</html>